﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.Common;
using Husb.Data;
using Husb.DataUtil;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Caching;

using CentralOffice.PublicAffair.Data;

using NoticeTable = CentralOffice.PublicAffair.Data.NoticeDataSet.NotificationsDataTable;
using NoticeRow = CentralOffice.PublicAffair.Data.NoticeDataSet.NotificationsRow;


namespace CentralOffice.PublicAffair.DataAccess
{
    public class NotificationAdapter : DataAccessAdapter<NoticeDataSet, NoticeTable, NoticeRow>
    {
        private const string UpdateStatusStoredProc = "Tasks.Tasks_UpdateTaskStatus";
        private const string SelectTaskAttendmentsByIdStoredProc = "Tasks.Tasks_SelectTaskAttendmentsById";
        private const string SelectTaskByEmployeeStoredProc = "Tasks.Tasks_SelectTaskByEmployee";
        public NotificationAdapter()
        {
            this.TableName = "Notifications";

            GetAllStoredProc = "PublicAffairs.Notifications_SelectNotificationsAll";
            InsertStoredProc = "PublicAffairs.Notifications_InsertNotification";
            UpdateStoredProc = "PublicAffairs.Notifications_UpdateNotification";
            DeleteStoredProc = "PublicAffairs.Notifications_DeleteNotification";

            GetByIdStoredProc = "PublicAffairs.Notifications_SelectNotification";
            GetByNameStoredProc   = "";
            GetPagedStoredProc = "PublicAffairs.Notifications_SelectNotificationsPaged";
            GetRowCountStoredProc = "PublicAffairs.Notifications_SelectNotificationsRowCount";

            FindStoredProc = "PublicAffairs.Notifications_SelectNotificationsDynamic";

            LogicalDeleteStoredProc = "PublicAffairs.Posts_DeletePost";
        }

        protected override void PopulateInsertParameters(Database db, DbCommand cmd)
        {
            db.AddInParameter(cmd, "Id", DbType.Guid, "Id", DataRowVersion.Current);
            db.AddInParameter(cmd, "Name", DbType.AnsiString, "Name", DataRowVersion.Current);
            db.AddInParameter(cmd, "NoticeNumber", DbType.AnsiString, "NoticeNumber", DataRowVersion.Current);
            db.AddInParameter(cmd, "QueryNumber", DbType.AnsiString, "QueryNumber", DataRowVersion.Current);
            db.AddInParameter(cmd, "Significant", DbType.AnsiString, "Significant", DataRowVersion.Current);
            db.AddInParameter(cmd, "Profile", DbType.AnsiString, "Profile", DataRowVersion.Current);
            db.AddInParameter(cmd, "IsTop", DbType.Boolean, "IsTop", DataRowVersion.Current);
            db.AddInParameter(cmd, "Accepter", DbType.AnsiString, "Accepter", DataRowVersion.Current);
            db.AddInParameter(cmd, "ReceiverType", DbType.Int32, "ReceiverType", DataRowVersion.Current);
            db.AddInParameter(cmd, "PublishDate", DbType.DateTime, "PublishDate", DataRowVersion.Current);
            db.AddInParameter(cmd, "Status", DbType.AnsiString, "Status", DataRowVersion.Current);
            db.AddInParameter(cmd, "ContentText", DbType.String, "ContentText", DataRowVersion.Current);
            db.AddInParameter(cmd, "Attachments", DbType.String, "Attachments", DataRowVersion.Current);
            db.AddInParameter(cmd, "IsDeleted", DbType.Boolean, "IsDeleted", DataRowVersion.Current);
            db.AddInParameter(cmd, "IsActive", DbType.Boolean, "IsActive", DataRowVersion.Current);
            db.AddInParameter(cmd, "CreatedTime", DbType.DateTime, "CreatedTime", DataRowVersion.Current);
            db.AddInParameter(cmd, "CreatedBy", DbType.Guid, "CreatedBy", DataRowVersion.Current);
            db.AddInParameter(cmd, "ModifiedTime", DbType.DateTime, "ModifiedTime", DataRowVersion.Current);
            db.AddInParameter(cmd, "LastModifiedBy", DbType.Guid, "LastModifiedBy", DataRowVersion.Current);
            db.AddInParameter(cmd, "Version", DbType.Int32, "Version", DataRowVersion.Current);
            db.AddInParameter(cmd, "Description", DbType.String, "Description", DataRowVersion.Current);
        }
    }
}
